package book;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 黎鹤舞
 * Date: 2023-11-20
 * Time: 21:44
 */

//这里是书的对象类，用来表示具体的书籍信息
public class Book {
    //Java中，字段应该尽量做到封装
    private String name;
    private String author;
    private int price;
    private String type;
    private boolean isBorrowed;

    //这里是Getter and Setter方法
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public boolean isBorrowed() {
        return isBorrowed;
    }

    public void setBorrowed(boolean borrowed) {
        isBorrowed = borrowed;
    }


    //这里是构造方法
    //在这里我们可以不传递isBorrowed，因为boolean类型默认的返回值类型就是false
    public Book(String name, String author, int price, String type) {
        this.name = name;
        this.author = author;
        this.price = price;
        this.type = type;
    }


    //toString方法的重写:便于后续打印
    @Override
    public String toString() {
        return "Book{" +
                "书名:'" + name + '\'' +
                ", 作者:'" + author + '\'' +
                ", 价格:" + price +
                ", 种类:'" + type + '\'' +
                ", 书籍借出状态:" + ((isBorrowed == true)?",已借出":",未借出") +
                '}';
    }
}
